class Factory {
    private final Map<String, FruitState> states = new HashMap<>();

    public Factory() {
        // 初始化状态映射
        states.put("A", new AppleState());
        states.put("B", new BananaState());
    }

    public Fruit CreateFruit(String kind) {
        FruitState state = states.get(kind);
        if (state != null) {
            return state.create();
        }
        return null;
    }
}